
from Rexcel import *
class Dbmanager:

    @staticmethod
    def table_insert(path,tablename):
        # 根据excel生成数据库表
        # [('userId', 'username', 'passwd', 'usersex', 'userage', 'userbirthday'), (1, '张三1', 123456, 1, 23, 20210203), (2, '张三2', 123457, 0, 23, 20210204)]]\、
        readexcel = Rexcel().readExcel(path,tablename)
        values = str(readexcel[1:-1])[1:-1]
        tabletitle = str(readexcel[0])[1:-1].replace("'",'')
        return f'insert into {tablename}  ({tabletitle})  values {values}'
    @staticmethod
    def trimfuhao(string):
        return string.replace("'",'')

if __name__ == '__main__':
    print(Dbmanager.table_insert(r'E:\啄木鸟47软件测试开发培训\shyoldboy\utils\resources\bolgsys.xlsx','student'))
